import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'
import {routerStatus} from '@/pinia'

const routes: RouteRecordRaw[] = [
    {
        path: '/',
        name: 'index',
        component: () => import('@/components/layout/index.vue'),
        children: [
            {
                path: '/',
                name: 'indexPage',
                component: () => import('@/view/index/index.vue')
            },
            {
                path: '/hotspot',
                name: 'hotspot',
                component: () => import('@/view/hotspot/index.vue')
            },
            {
                path: '/push',
                name: 'push',
                component: () => import('@/view/push/index.vue')
            },
            {
                path: '/vip',
                name: 'vip',
                component: () => import('@/view/vip/index.vue')
            },
            {
                path: '/my',
                name: 'my',
                component: () => import('@/view/my/index.vue')
            },
            {
                path: '/play',
                name: 'play',
                component: () => import('@/view/playInfo/index.vue'),
                children: []
            }
        ]
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes,
})

router.beforeEach((to, from, next) => {
    const isPlay = to.path.startsWith('/play')
    routerStatus().setIsTabs(!isPlay)
    next()
    console.log(`源路由: ${from.path}`)
})

export default router
